/******************************************************************************* * Copyright (c) 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.refactoring.infra; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.ltk.core.refactoring.CheckConditionsOperation; import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation; import org.eclipse.ltk.core.refactoring.Refactoring; import org.eclipse.ltk.core.refactoring.RefactoringCore; public abstract class RefactoringHeapTestCase extends RefactoringPerformanceTestCase { public RefactoringHeapTestCase() { super(); } public RefactoringHeapTestCase(String name) { super(name); } protected void executeRefactoring(Refactoring refactoring, boolean measure, int maxSeverity, boolean checkUndo) throws Exception { PerformRefactoringOperation operation= new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS); joinBackgroudActivities(); // Flush the undo manager to not count any already existing undo objects // into the heap consumption RefactoringCore.getUndoManager().flush(); System.gc(); if (measure) startMeasuring(); ResourcesPlugin.getWorkspace().run(operation, null); if (checkUndo) assertNotNull(operation.getUndoChange()); assertEquals(true, operation.getConditionStatus().getSeverity() <= maxSeverity); assertEquals(true, operation.getValidationStatus().isOK()); RefactoringCore.getUndoManager().flush(); System.gc(); if (measure) finishMeasurements(); } }